<include file="../Public/plugin.header.html" />
<link href="__PUBLIC__/Css/plugin-gift.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
    //鼠标移动表格效果
    $(document).ready(function(){
    	inittable();
    	<php>if(!empty($_REQUEST['order_id'])){</php>
    	$('.gift_list > #order_list').find('tr').each(function(){
    		if($(this).attr('rel')!='order_{$_REQUEST['order_id']}'&&$(this).attr('rel')!='order_title')$(this).hide();
    	});
    	$('#show_order_page').hide();
    	//$('#show_order_list').show();
    	$('#ajx_show_area').show();
    	<php>}</php>
    	<php>if(!empty($_REQUEST['paytype'])){</php>
			doPay();
		<php>}</php>
		
    });
    
    function inittable(){
        $(".list").find('tr').hover(
          function () {
            $(this).addClass("bg_hover");
          },
          function () {
            $(this).removeClass("bg_hover");
          }
        );
    }
    
    function showOrderList(oid){
    	$('.list > #order_list').find('tr').each(function(){
    		$(this).show();
    	});
    	//$('#show_order_list').hide();
    	$('#show_order_page').show();
    	$('#ajx_show_area').hide();
    }
    
    
    function goPage(pno){
    	showOrderList();
 		$.kajax({      
			url:"{:U('plugin://order/ajxSendList')}",      
			type:'post', //数据发送方式  
			data:{pno:pno,stype:$('#ajx_show_area_gift_list').find('#stype').val()} ,    
			async: false ,//同步方式     
			success: function(html){ 
				$('#ajx_show_area_gift_list').html(html);
			}
		});
 	}

    function ajxDeleteOrder(oid){
    	$.kajax({      
    		ajx_rtn_type:'JSON',
    		url:"{:U('plugin://order/ajxDeleteOrder')}",      
    		type:'post', //数据发送方式  
    		data:{order_id:oid} ,    
    		async: false ,//同步方式     
    		success: function(jsonobj){ 
    			if(jsonobj.status==1){
    				k_success(jsonobj.msg);
    				goPage(1);
    			}else{
    				k_error(jsonobj.msg);
    			}
    		}
    	});
    }

    function showOrderDetail(oid){
    	$('.list > #order_list').find('tr').each(function(){
    		if($(this).attr('rel')!='order_'+oid&&$(this).attr('rel')!='order_title')$(this).hide();
    	});
    	$('#show_order_page').hide();
    	$('#ajx_show_area').show();
    	$('#ajx_show_area_detail').html($('#show_loading_html').html());
    	$.kajax({      
    		url:"{:U('plugin://order/ajxDetail')}",      
    		type:'post', //数据发送方式  
    		data:{order_id:oid} ,    
    		async: false ,//同步方式     
    		success: function(html){ 
    			$('#ajx_show_area_detail').html(html);
    		}
    	});
    }

	function getBMVCode() {
		$('#btn_get_bmvcode').attr('disabled','true');
		var mobile = $('#mobile').val();
		k_ajaxRequest("{:U('plugin://order/sendBMVerifyCode')}",
					{mobile:mobile},
					function(){ $('#btn_get_bmvcode').removeAttr('disabled'); },
					function(){ $('#btn_get_bmvcode').removeAttr('disabled'); }
				);
	}
	
	function doBindMobile() {
		$('#btn_bind_mobile').attr('disabled','true');
		var mobile = $('#mobile').val();
		var verify = $('#verify').val();
		k_ajaxRequest("{:U('plugin://order/bindMobile')}",
					{mobile:mobile,verify:verify},
					function(){ $('#btn_bind_mobile').removeAttr('disabled');
								windowreload();
							  },
					function(){ $('#btn_bind_mobile').removeAttr('disabled'); }
				);
	}
	
	function doUnbindMobile(){
		$('#btn_unbind_mobile').attr('disabled','true');
		k_ajaxRequest("{:U('plugin://order/unBindMobile')}",
						null,
						function(){ $('#btn_unbind_mobile').removeAttr('disabled');
										windowreload();
								  },
						function(){ $('#btn_unbind_mobile').removeAttr('disabled'); }
					);
	}
</script>
<div id="g_plugin_main">
<!--页面主部-->
<div class="p_main" id="p_main">
	<div class="blank5"></div>
	<div class="primary_box">
		<div class="primary_box" id="topbar">
			<div class="step">
			        <div class="cont" style="padding-top: 0px;">
		        		<span style="float:right;margin-top: 5px;">
		        			您通过{$user['agent']['title']}下的订单！
		        			<php>if( !empty($plugin_bindmobile) ){</php>
		        				当前手机：{$plugin_bindmobile}&nbsp;&nbsp;
		        				<a href="javascript:doUnbindMobile()" style="color: #3B5999;">换手机</a>
		        			<php>}else{</php>
		        			<php>}</php>
		        		</span>
		        		<h2 class="subStep" style="height: 10px;">订单列表</h2>
		        		<div class="clear"></div>
		        		
		        		<php>if( !isValidMobile( $plugin_bindmobile ) ){</php>
		        		<!-- 需要临时绑定手机号码才能查看  -->
		        		<div id='dobind_area' class="data" style="display: block; text-align: center;" >
		        			<div class="blank10"></div><div class="blank10"></div>
		        			<span style="height:25px;color: #CC0000;font-weight:bold;">请临时验证手机号码</span>
		        			<div class="blank10"></div>
		        			<span style="height:30px;">
								手机号码：<input id="mobile" type="text" class="normal_input" style="width:110px" />
								&nbsp;&nbsp;
								验证码：<input id="verify" type="text" class="normal_input" style="width:40px"/>
								&nbsp;&nbsp;
								<input type="button" onclick="getBMVCode()" id="btn_get_bmvcode" title="点击获取验证码，验证码将发送到手机！" value="获取" class="btn_w">
								&nbsp;&nbsp;		
								<input type="button" class="btn_r" value="验证手机" id="btn_bind_mobile" onclick="doBindMobile();" />
							</span>
						</div>
		        		<php>}else{</php>
			        		<div id="ajx_show_area_gift_list">
							  	<include file="../plugin/Tpl/default/order/list_box.html" />
							</div>
							<div id="clear"></div>
							  
							<div id="ajx_show_area" style="margin-top:20px;display: none;">
								<span style="float:right;padding-top: 5px;cursor: pointer;" onclick="showOrderList()">显示列表&nbsp;</span>
			        			<h2 class="subStep" style="height: 10px;">订单详情</h2>
			        			<div class="clear"></div>
								<div id="ajx_show_area_detail">     
								<php>$order_id=$_REQUEST['order_id'];$paytype=$_REQUEST['paytype'];
								</php> 	
							  		<include file="../plugin/Tpl/default/order/detail_box.html" />
								</div>
						   	</div>
					   	<php>}</php>
		        		
						<div id="clear"></div>
						
					</div>
			</div>
		</div>
	</div>
</div>
</div>	  					    		
<include file="../Public/plugin.footer.html" />